/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author antonio
 */
@Entity
@Table(name = "Civilian")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Civilian.findAll", query = "SELECT c FROM Civilian c"),
    @NamedQuery(name = "Civilian.findByVillager", query = "SELECT c FROM Civilian c WHERE c.villager = :villager")})
public class Civilian implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "villager")
    private Integer villager;
    @JoinColumn(name = "villager", referencedColumnName = "unit", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Villager villager1;

    public Civilian() {
    }

    public Civilian(Integer villager) {
        this.villager = villager;
    }

    public Integer getVillager() {
        return villager;
    }

    public void setVillager(Integer villager) {
        this.villager = villager;
    }

    public Villager getVillager1() {
        return villager1;
    }

    public void setVillager1(Villager villager1) {
        this.villager1 = villager1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (villager != null ? villager.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Civilian)) {
            return false;
        }
        Civilian other = (Civilian) object;
        if ((this.villager == null && other.villager != null) || (this.villager != null && !this.villager.equals(other.villager))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Civilian[ villager=" + villager + " ]";
    }
    
}
